home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / Periodic Tasksƒ / CPPSpawnZoneTask.cp < prev    next >
Encoding:
Text File  |  1996-04-04  |  2.2 KB  |  85 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    9/17/93
  3.     AUTHOR: Eric R. Rosé
  4.     
  5.     CLASS:  CPPSpawnZoneTask
  6.     
  7.     SUPERCLASS: CPPPeriodicTask
  8.     
  9.         This C++ class periodically spawns a ScanZoneTask
  10.     
  11. ********************************************************************/
  12.  
  13. #include <CPPTaskManager.h>
  14. #include <CPPStringList.h>
  15. #include "CPPSpawnZoneTask.h"
  16. #include "CPPScanZones.h"
  17.  
  18. /*-----------------------------------------------------------------*/
  19. /*------------------------ PUBLIC METHODS -------------------------*/
  20. /*-----------------------------------------------------------------*/
  21.  
  22.     CPPSpawnZoneTask::CPPSpawnZoneTask (CPPTaskManager *TaskManager, 
  23.                                         long minPeriod, 
  24.                                         Boolean deleteWhenDone) :
  25.                               CPPPeriodicTask (TaskManager, minPeriod,
  26.                                              deleteWhenDone)
  27.     {
  28.         this->scanTask = NULL;
  29.     }
  30.     
  31. /*-----------------------------------------------------------------*/
  32.  
  33.     CPPSpawnZoneTask::~CPPSpawnZoneTask (void)
  34.     {
  35.         if (this->scanTask)
  36.           delete this->scanTask;
  37.     }
  38.     
  39. /*-----------------------------------------------------------------*/
  40.  
  41.     char *CPPSpawnZoneTask::ClassName (void)
  42.     {
  43.         return "CPPSpawnZoneTask";
  44.     }
  45.  
  46. /*-----------------------------------------------------------------*/
  47.  
  48.     void    CPPSpawnZoneTask::DoPeriodicAction (void)
  49.     /* if the Scan task has completed, ask it to scan again; */
  50.     /* NOTE:  this task never completes */
  51.     {        
  52.         // call the inherited method to update frequency count
  53.         CPPPeriodicTask::DoPeriodicAction();
  54.  
  55.         if (scanTask->hasCompleted)
  56.           scanTask->StartScanZones (NULL);
  57.     }
  58.  
  59. /*-----------------------------------------------------------------*/
  60.  
  61.     void    CPPSpawnZoneTask::DoCompletedAction (void)
  62.     {
  63.         CPPPeriodicTask::DoCompletedAction();
  64.     }
  65.  
  66. /*-----------------------------------------------------------------*/
  67.  
  68.     void CPPSpawnZoneTask::StartSpawnZoneTask 
  69.                                 (CompletionProc DoProc)
  70.     {
  71.         if (!this->hasCompleted)
  72.           return;
  73.           
  74.         // get rid of the old lookup and zone data (if any)
  75.         if (!scanTask)
  76.           scanTask = new CPPScanZones (this->ourManager, 60, FALSE);
  77.               
  78.         // note that we haven't completed yet
  79.         SetCompletionProc(DoProc);
  80.         this->hasCompleted = FALSE;
  81.         
  82.         // add ourselves to the periodic task queue
  83.         this->ourManager->AddPeriodicTask(this);
  84.     }
  85.